<script setup lang="ts">

import { ref, computed, onMounted } from 'vue'
import type { Ref } from 'vue'

const tel: Ref<string> = ref('')
function onSubmit() {
    //提交的方法
}
const flag = computed(() => {
    return /^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(tel.value) != true
}
)
import { useRoute, useRouter } from 'vue-router';
const route = useRoute()
const router = useRouter()
import { docheckphoneFn } from '@/api/register'
import { showToast } from 'vant';//导入轻提示组件

function step1Click() {
    // console.log(route,router);
    docheckphoneFn({ tel: tel.value }).then(res => {
        console.log(1, res);
        console.log(1111, res.data.code);
        
        if (res.data.code == 200) {
            localStorage.setItem('tel', tel.value)//本地存储手机号
            showToast(res.data.message)
            router.push('/register/step2')

        }else{
           showToast(res.data.message)
        }
        // showToast(res.data.message)
        // router.push('/register/step2')
    })

}



</script>

<template>

    <van-form @submit="onSubmit">
        <van-cell-group inset style="height: 120px;">
            <van-field v-model="tel" name="手机号" label="手机号" placeholder="手机号"
                :rules="[{ required: true, message: '请填写手机号' }]" />

        </van-cell-group>
        <div style="margin: 16px;">
            <van-button :disabled="flag" round block color="#f66" native-type="submit" @click="step1Click">
                下一步
            </van-button>
        </div>

    </van-form>

</template>
